#ifndef LEAK_DETECTOR_H_
#define LEAK_DETECTOR_H_
#include <cstdio>
void* operator new(size_t size, char* file, size_t line);
void* operator new[](size_t size, char* file, size_t line);

void operator delete(void* ptr);
void operator delete[](void* ptr);

#ifndef NEW_OVERLOAD_IMPLEMENTATION_
#define new new( __FILE__, __LINE__ )
// 在检测器具体实现的文件中，保留原本的new操作
#endif

class LeakDetector{
public:
    static size_t _callCount;
    LeakDetector(){++_callCount;}
    ~LeakDetector(){
        if(0==--_callCount) _LeakDetect();
        }
private:
    void _LeakDetect();
};

static LeakDetector exitCountor;
#endif